/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ShapeService.bouncebox;

import ShapeService.bounceboxframework.Shape;
import java.awt.Graphics2D;

public class Triangle extends Shape {

    private double contactRadius;
    private int base;
    private int height;

    public Triangle(int x, int y, int base, int height) {
        super(x,y);
        this.base = base;
        this.height = height;
        contactRadius = (Math.pow(base/2.0, 2) + Math.pow(height, 2)) / (2 * height) * 0.9;
    }

    public int getBase(){return base;}
    public int getHeight(){return height;}

    public double getContactRadius() {return contactRadius;}
    public double getMass() {return (base * height) / 2.0;}

    public void draw(Graphics2D g) {
        g.setColor(getColor());
        int[] xPoints = {
            (int)getX(),
            (int)(getX() - (double) base /2),
            (int)(getX() + (double) base /2)
        };
        int[] yPoints = {
            (int)(getY() - (double) height /2),
            (int)(getY() + (double) height /2),
            (int)(getY() + (double) height /2)
        };
        g.fillPolygon(xPoints, yPoints, 3);
    }
}
